export default class NumberIDGenerator {
  static SERIES_NUMBER = 0;

  static seed = Math.round(Date.now() / 1000);

  static seriesLength = 3;

  static gen() {
    const now = Date.now();
    if (now === NumberIDGenerator.seed) {
      NumberIDGenerator.SERIES_NUMBER++;
    } else {
      NumberIDGenerator.SERIES_NUMBER = 0;
    }
    let seriesNumber = `000000000${NumberIDGenerator.SERIES_NUMBER}`;
    seriesNumber = seriesNumber.substr(seriesNumber.length - NumberIDGenerator.seriesLength);
    return Number(`${now}${seriesNumber}`);
  }
}
